package com.junjie.checkin.entity.Enum;

import com.fasterxml.jackson.annotation.JsonCreator;
import lombok.Getter;

/**
 * @author 洪浚杰
 * @description 活动签到方式枚举
 * @date 2025/6/13 14:44
 */

@Getter
public enum ActivityCheckInMethodEnum implements StringValuedEnum {
    QRCODE("qrcode", 1),
    LOCATION("location", 2),
    BOTH("both", 3);

    private final String value;
    private final int index;

    ActivityCheckInMethodEnum(String value, int index) {
        this.value = value;
        this.index = index;
    }

    @Override
    public String getValue() {
        return value;
    }



    @JsonCreator
    public static ActivityCheckInMethodEnum fromValue(String value) {
        for (ActivityCheckInMethodEnum e : values()) {
            if (e.getValue().equalsIgnoreCase(value)) {
                return e;
            }
        }
        throw new IllegalArgumentException("No enum constant for value: " + value);
    }

    public static ActivityCheckInMethodEnum fromIndex(int index) {
        for (ActivityCheckInMethodEnum e : values()) {
            if (e.getIndex() == index) {
                return e;
            }
        }
        throw new IllegalArgumentException("No enum constant for index: " + index);
    }
}
